home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / backdrp2.arc / BACKDROP.ASM next >
Assembly Source File  |  1990-10-12  |  12KB  |  314 lines

  1. ;┌───────────────────────────────────────────────────────────┐
  2. ;│ BACKDROP.ASM                                              │
  3. ;├───────────────────────────────────────────────────────────┤
  4. ;│                                                           │
  5. ;│ This program displays a 'backdrop' for DESQview.  It is   │
  6. ;│ similar to wall-paper type programs in X-Windows.         │
  7. ;│ It displays the TIME, MEMORY STATUS, and a simple         │
  8. ;│ logo showing the version of DESQview running.             │
  9. ;│                                                           │
  10. ;│ NOTES: Take a look at the ORPHAN window data stream.      │
  11. ;│ This stream ORPHANS the parent window.  The effect is to  │
  12. ;│ remove it from the DESQview switch windows list.  It can  │
  13. ;│ be added back to the switch windows list by sending any   │
  14. ;│ manager stream commmand.                                  │
  15. ;│                                                           │
  16. ;│ The program increases the logical and physical window     │
  17. ;│ size to 60 x 80 to allow it to be 'full screen' in        │
  18. ;│ 25,43,50, and 60 line modes.  If you have setup for       │
  19. ;│ Hercules or Genius you will need to modify the init_strm  │
  20. ;│ window data stream.  Refer to init_log and init_phys      │
  21. ;│ in BACKDROP.DAT                                           │
  22. ;│                                                           │
  23. ;├───────────────────────────────────────────────────────────┤
  24. ;│ To create BACKDROP.ASM                                    │
  25. ;│                                                           │
  26. ;│ > MASM BACKDROP;                                          │
  27. ;│ > LINK BACKDROP;                                          │
  28. ;│ > EXE2BIN BACKDROP.EXE BACKDROP.COM                       │
  29. ;└───────────────────────────────────────────────────────────┘
  30.  
  31.             title backdrop
  32.             page  60,132
  33.  
  34.  
  35. code        segment
  36.             assume cs:code,ds:code
  37.             org   0100h
  38.  
  39. entry:      jmp   start
  40.  
  41. include     dvapi.inc                  ;API macro file
  42. include     dvapi.mac                  ;My extensions
  43. include     dvapi.equ                  ;  "     "
  44. include     backdrop.dat
  45.  
  46. start:      mov   ax,cs                ;setup data segment
  47.             mov   ds,ax
  48.  
  49.             @call dvpresent            ;check for DESqview
  50.             test  ax,ax
  51.             jz    eoj                  ;if not present, exit
  52.             mov   ver,ax
  53.             call  inits                ;get object handles and setup window
  54.  
  55. main:
  56.             call  chk_mem
  57.             call  set_time             ;display time
  58.             jmp   main                 ;loop indefinitely
  59.  
  60. eoj:
  61.             mov   ah,4ch
  62.             int   21h
  63.  
  64. ;┌───────────────────────────────────────────────────────────┐
  65. ;│ inits: get handles, display time, start timer             │
  66. ;├───────────────────────────────────────────────────────────┤
  67. ;│ input:                                                    │
  68. ;│  none                                                     │
  69. ;│ output:                                                   │
  70. ;│  none                                                     │
  71. ;└───────────────────────────────────────────────────────────┘
  72.  
  73. inits       proc  near
  74.             @send new,timer
  75.             @pop  tim
  76.             @send handle,me
  77.             @pop  win
  78.             mov   ax,ver
  79.             add   ah,'0'
  80.             mov   logo_vers,ah
  81.             xor   ah,ah
  82.             mov   dx,ax
  83.             mov   bx,offset logo_vers+2
  84.             mov   cnvtcnt,2
  85.             call  bin2dec
  86.             @strm init_strm,win
  87.             call  fill_screen
  88.             @strm text_strm,win
  89.             @strm logo_strm,win
  90. init_orphan:
  91.             @strm orphan,win
  92.             ret
  93. inits       endp
  94.  
  95. ;┌───────────────────────────────────────────────────────────┐
  96. ;│ set_time: update the time display and reset timer         │
  97. ;├───────────────────────────────────────────────────────────┤
  98. ;│ input:                                                    │
  99. ;│  none                                                     │
  100. ;│ output:                                                   │
  101. ;│  none                                                     │
  102. ;└───────────────────────────────────────────────────────────┘
  103.  
  104. set_time    proc  near
  105.             call  get_time             ;get current time
  106.             call  get_date             ;get current date
  107.  
  108.             mov   si,offset updt_strm  ;send stream to update date and time
  109.             mov   cx,updt_strml
  110.             call  win_me
  111.  
  112.             mov   cx,100               ;1 second delay
  113.             xor   dx,dx                ;clear high word
  114.             @push dxcx                 ;push delay
  115.             @send addto,tim            ;set timer
  116.             ret
  117. set_time    endp
  118.  
  119. ;┌───────────────────────────────────────────────────────────┐
  120. ;│ get_time: get system time, format for display             │
  121. ;├───────────────────────────────────────────────────────────┤
  122. ;│ input:                                                    │
  123. ;│  none                                                     │
  124. ;│ output:                                                   │
  125. ;│  none                                                     │
  126. ;└───────────────────────────────────────────────────────────┘
  127.  
  128. get_time    proc  near
  129.             mov   di,offset stime      ;output buffer
  130.             mov   ah,2ch               ;get system time
  131.             int   21h
  132.             mov   al,ch
  133.             call  unpack               ;display hour
  134.             mov   al,cl
  135.             call  unpack               ;display minutes
  136.             mov   al,dh
  137.             call  unpack               ;display seconds
  138.             ret
  139. get_time    endp
  140.  
  141. ;┌───────────────────────────────────────────────────────────┐
  142. ;│ get_date: get system date, format for display             │
  143. ;├───────────────────────────────────────────────────────────┤
  144. ;│ input:                                                    │
  145. ;│  none                                                     │
  146. ;│ output:                                                   │
  147. ;│  none                                                     │
  148. ;└───────────────────────────────────────────────────────────┘
  149.  
  150. get_date    proc  near
  151.             mov   di,offset sdate      ;output buffer
  152.             mov   ah,2ah               ;get system date
  153.             int   21h
  154.             mov   al,dh
  155.             call  unpack               ;write month
  156.             mov   al,dl
  157.             call  unpack               ;write day
  158.             sub   cx,1900              ;subtract centuries
  159.             cmp   cx,100               ;still > 100?
  160.             jl    date_write           ;if not, write it
  161.             sub   cx,100               ;else, subtract out for > 2000
  162. date_write: mov   al,cl                ;get year
  163.             call  unpack               ;write year
  164.             ret
  165. get_date    endp
  166.  
  167. ;┌───────────────────────────────────────────────────────────┐
  168. ;│ unpack: unpack binary to 2 byte ascii decimal             │
  169. ;├───────────────────────────────────────────────────────────┤
  170. ;│ input:                                                    │
  171. ;│  al binary value to unpack                                │
  172. ;│  di pointer to output buffer                              │
  173. ;│ output:                                                   │
  174. ;│  di incremented by 3                                      │
  175. ;│  ax destroyed                                             │
  176. ;└───────────────────────────────────────────────────────────┘
  177.  
  178. unpack      proc  near
  179.             aam                        ;divide al by 10.
  180.             add   ax,3030h             ;convert digits to ascii.
  181.             mov   [di],ah              ;write 10's digit
  182.             inc   di                   ;next offset
  183.             mov   [di],al              ;write units digit
  184.             inc   di                   ;next offset
  185.             inc   di                   ;skip past separator
  186.             ret
  187. unpack      endp
  188.  
  189. ;┌───────────────────────────────────────────────────────────┐
  190. ;│ fill_screen: fill the screen with alternating box chars   │
  191. ;└───────────────────────────────────────────────────────────┘
  192.  
  193. fill_screen proc  near
  194.  
  195. boxa        equ   176
  196. boxb        equ   177
  197.             cld
  198.             mov   cx,4800
  199.             @call shadow
  200.             mov   ah,attr
  201.             mov   al,boxa
  202.             xor   dx,dx
  203. fill_loop:
  204.             stosw
  205.             inc   dx
  206.             cmp   dx,80
  207.             jne   exchg
  208.             xor   dx,dx
  209.             jmp   loop_end
  210. exchg:      cmp   al,boxa
  211.             jne   get_boxa
  212.             mov   al,boxb
  213.             jmp   loop_end
  214. get_boxa:   mov   al,boxa
  215. loop_end:   loop  fill_loop
  216.             ret
  217. fill_screen endp
  218.  
  219. ;┌───────────────────────────────────────────────────────────┐
  220. ;│ ckk_mem: check the various API memory calls               │
  221. ;└───────────────────────────────────────────────────────────┘
  222.  
  223. chk_mem     proc  near
  224.             @call commonmem
  225.             mov   ax,offset com_strm+1
  226.             call  write_mem
  227.             @call convenmem
  228.             mov   ax,offset con_strm
  229.             call  write_mem
  230.             @call expandmem
  231.             mov   ax,offset exp_strm
  232.             call  write_mem
  233.             @strm mem_strm,win
  234.             ret
  235. chk_mem     endp
  236.  
  237. ;┌───────────────────────────────────────────────────────────┐
  238. ;│ write_mem: write the values to the parent window          │
  239. ;└───────────────────────────────────────────────────────────┘
  240.  
  241. write_mem   proc  near
  242.             push  cx
  243.             push  bx
  244.             push  dx
  245.             mov   bx,ax
  246.             mov   cx,3
  247. write_mem_loop:
  248.             pop   dx
  249.             mov   cnvtcnt,5
  250.             call  bin2dec
  251.             add   bx,4
  252.             loop  write_mem_loop
  253.             ret
  254. write_mem   endp
  255.  
  256. ;┌───────────────────────────────────────────────────────────┐
  257. ;│ bin2dec: convert 2 byte binary to ascii decimal           │
  258. ;├───────────────────────────────────────────────────────────┤
  259. ;│ input:                                                    │
  260. ;│   dx   value to convert                                   │
  261. ;│   bx   destination                                        │
  262. ;│ output:                                                   │
  263. ;│   none                                                    │
  264. ;└───────────────────────────────────────────────────────────┘
  265.  
  266. bin2dec     proc  near
  267.             push  cx
  268.  
  269.             mov   ax,dx                ;save value
  270.             mov   si,10                ;get divisor
  271.             xor   cx,cx                ;zero out for counting digits
  272. bin2dec_loop:
  273.             xor   dx,dx                ;zero out
  274.             div   si                   ;divide value by ten
  275.             push  dx                   ;stack digits in reverse order
  276.             inc   cx                   ;increment digit counter
  277.             or    ax,ax                ;zero yet?
  278.             jne   bin2dec_loop         ;if not, loop
  279.             xor   dx,dx
  280. bin2dec_pad:
  281.             cmp   cx,cnvtcnt
  282.             jge   bin2dec_begin        ;if yes, go write them
  283.             push  dx                   ;push zero pad
  284.             inc   cx                   ;increment digit count
  285.             jmp   bin2dec_pad          ;loop
  286. bin2dec_begin:
  287.             xor   dx,dx
  288. bin2dec_char:
  289.             pop   ax                   ;pop digit
  290.             cmp   dx,1
  291.             je    bin2dec_add
  292.             cmp   al,0
  293.             jne   bin2dec_blankoff
  294.             mov   al,' '
  295.             jmp   bin2dec_write
  296. bin2dec_blankoff:
  297.             mov   dx,1
  298. bin2dec_add:
  299.             add   al,'0'               ;convert to ascii
  300. bin2dec_write:
  301.             mov   [bx],al
  302.             inc   bx
  303.             loop  bin2dec_char         ;loop till all char written
  304.  
  305.             pop   cx
  306.             ret                        ;return
  307. bin2dec     endp
  308.  
  309. include     win_me.inc
  310. include     win_strm.inc
  311.  
  312. code        ends
  313.             end   entry
  314.